<?php
set_time_limit(0);
$root=preg_replace('/cron$/', '', dirname(__FILE__));

require_once($root."inc.config.php");

require_once($root."initialize.php");

if(($db_msg=cron_initialize()) !== true){

	print_r("Connection error");

}else{ 

	$db=$vars["db"];

	
		$t = @mysql_num_rows($r=mysql_query("SELECT *,SUBSTR(descr,14,11) as bonus_date FROM gg_member_mwallet_record WHERE descr like 'Auto Maintain 2%'"));
		
		if($t<=0)
		{
			print_r("no record");
			exit;
		}

		while($maintain = mysql_fetch_assoc($r))
		{
			if($maintain['cdate']=='2011-03-05 02:22:39') $bonus_date = '2010-02-28';
			else $bonus_date = $maintain['bonus_date'];

			$sql = "INSERT INTO gg_member_maintain SET uid=".$maintain['uid'].",credit=".$maintain['amount'].",rate=1,percent=30,amount=".$maintain['amount'].",cdate='".$maintain['cdate']."',bonus_date='".$bonus_date."'";
			mysql_query($sql);
		}

	print_r("finish");
}
?>